package com.example.cici.cclight;

import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

public class Main_activity extends AppCompatActivity {
    private BluetoothAdapter bluetoothAdapter;
    private Button btn_switch;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_layout);
        //判断是否打开了蓝牙
        bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        if (bluetoothAdapter != null){
           btn_switch = (Button) findViewById(R.id.btn_switch);
           btn_switch.setOnClickListener(new View.OnClickListener() {
               @Override
               public void onClick(View v) {
                bluetoothAdapter.enable();
                   Intent intent = new Intent();
                   Bundle bundle = new Bundle();
//                   bundle.put
//                   bundle.putString("adapter",bluetoothAdapter);
//                   intent.putExtra(bundle);
                   intent.setClass(Main_activity.this,List_Bluetooth.class);
                   startActivity(intent);
               }
           });
        }
    }
}
